package com.zhny.view;

import com.zhny.meddleware.IViewMessenger;
import com.zhny.meddleware.SenderProxy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.TreeMap;

/**
 * Create By Alex On 2018/4/10 12:25
 */
@Component
public class ViewTest implements IViewMessenger {

    @Autowired
    private SenderProxy sender;

    private TreeMap<Integer,Short> deviceTable = new TreeMap<>();

    private void init(){
        deviceTable.put(180403514, (short) 514);
        sender.init(deviceTable);
        sender.register();
        sender.start();
    }

    @Override
    public void handleMessage(String message, Map<String, String> logMap) {
        System.out.println(message);
    }

    public static void main(String[] args) {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
        ViewTest viewTest = (ViewTest) applicationContext.getBean("viewTest");
        viewTest.init();
    }
}
